package net.podhradie.shared.servlets;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

public class Log4jInit extends HttpServlet {

	private static final long serialVersionUID = -3049732364307587744L;

	private static final Logger log = Logger.getLogger(Log4jInit.class.getName());

	public void init() {
		// String file = getInitParameter("log4j-init-file");
		String source = getInitParameter("source");
		System.out.println("############# SHARED INIT FROM application: "+source+" ##############");
		// String prefix = getServletContext().getRealPath("/");

		try {
			// PropertyConfigurator.configure(prefix + file);
			PropertyConfigurator.configure(this.getClass().getResourceAsStream("log4j.properties"));
			log.info("############# LOG4J configured from application: "+source+" ##############");
		} catch (Exception e) {
			System.out.println("############# SHARED LOG4J exception ##############");
			e.printStackTrace();
		}


	}

	public void doGet(HttpServletRequest req, HttpServletResponse res) {
	}
}